From 57afc457bc16cca04762391f77d22b9219cb0e5f Mon Sep 17 00:00:00 2001
From: Guiding Li <liguiding1@xiaomi.com>
Date: Tue, 20 Jul 2021 17:52:13 +0800
Subject: [PATCH 01/12] openamp: add ns_unbind_notify support

This is for notify rdev unbind event

Signed-off-by: Guiding Li <liguiding1@xiaomi.com>
---
 lib/include/openamp/rpmsg.h | 1 +
 lib/rpmsg/rpmsg_virtio.c    | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index 8b8ec2e..e6acce8 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -118,6 +118,7 @@ struct rpmsg_device {
 	unsigned long bitmap[metal_bitmap_longs(RPMSG_ADDR_BMP_SIZE)];
 	metal_mutex_t lock;
 	rpmsg_ns_bind_cb ns_bind_cb;
+	rpmsg_ns_bind_cb ns_unbind_cb;
 	struct rpmsg_device_ops ops;
 	bool support_ns;
 };
diff --git a/lib/rpmsg/rpmsg_virtio.c open-amp/lib/rpmsg/rpmsg_virtio.c
index 57a2083..d5f168c 100644
--- a/lib/rpmsg/rpmsg_virtio.c
+++ open-amp/lib/rpmsg/rpmsg_virtio.c
@@ -585,6 +585,9 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
 		metal_mutex_release(&rdev->lock);
 		if (_ept && _ept->ns_unbind_cb)
 			_ept->ns_unbind_cb(_ept);
+		if (rdev->ns_unbind_cb)
+			rdev->ns_unbind_cb(rdev, name, dest);
+
 	} else {
 		if (!_ept) {
 			/*
-- 
2.25.1

